*******************************************************************************
* Contributions, all states
*******************************************************************************

use dataset_donors, clear
	
keep if inlist(year, 2000, 2012)
gen post = year == 2012
gen anyfrackingXpost = anyfracking*post
gen in_shaleXpost = in_shale_pl*post

eststo clear
eststo: reg ltotamount anyfrackingXpost post, a(zipcode) cl(zipcode) // ols
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

eststo: reg ltotamount in_shaleXpost post, a(zipcode) cl(zipcode) // rf
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

eststo: reg anyfrackingXpost in_shaleXpost post, a(zipcode) cl(zipcode) // fs
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)
test in_shaleXpost = 0
estadd scalar fstat = r(F)

eststo: tsls ltotamount post (anyfrackingXpost = in_shaleXpost), ///
	demean fe(zipcode) cluster(zipcode) // ss
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

label variable anyfrackingXpost "Ever fracked X post"
label variable in_shaleXpost "In shale X post"

#delimit;

esttab
	using "_output/tableA4_a.tex"
	,
		replace
		booktabs
		keep(anyfrackingXpost in_shaleXpost) 
		cells(b(fmt(3) star) se(par))
		label
		gap
		collabels(none)	
		mtitles(
			"\shortstack{Contribs \\ (OLS)}" 
			"\shortstack{Contribs \\ (Reduced)}"
			"\shortstack{Ever fracked\\ X post (First)}"
			"\shortstack{Contribs \\ (Second)}"
		)
		width(\linewidth)
		stats(
			YFE
			ZFE
			Nzip
			N
			fstat
			,
				label(
					"Year fixed effects"
					"Zip code fixed effects" 
					"Clusters"
					"Observations"
					"F statistic"
				)
				fmt(0 %20.0fc)
		)
		;

#delimit cr

*******************************************************************************
* Contributions, high-fracking states
*******************************************************************************

keep if highf == 1
eststo clear
eststo: reg ltotamount anyfrackingXpost post, a(zipcode) cl(zipcode) // ols
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

eststo: reg ltotamount in_shaleXpost post, a(zipcode) cl(zipcode) // rf
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

eststo: reg anyfrackingXpost in_shaleXpost post, a(zipcode) cl(zipcode) // fs
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)
test in_shaleXpost = 0
estadd scalar fstat = r(F)

eststo: tsls ltotamount post (anyfrackingXpost = in_shaleXpost), ///
	demean fe(zipcode) cluster(zipcode) // ss
estadd local ZFE = "Yes"
estadd local YFE = "Yes"
estadd scalar Nzip = e(N_clust)

#delimit;

esttab
	using "_output/tableA4_b.tex"
	,
		replace
		booktabs
		keep(anyfrackingXpost in_shaleXpost) 
		cells(b(fmt(3) star) se(par))
		label
		gap
		collabels(none)	
		mtitles(
			"\shortstack{Contribs \\ (OLS)}" 
			"\shortstack{Contribs \\ (Reduced)}"
			"\shortstack{Ever fracked\\ X post (First)}"
			"\shortstack{Contribs \\ (Second)}"
		)
		width(\linewidth)
		stats(
			YFE
			ZFE
			Nzip
			N
			fstat
			,
				label(
					"Year fixed effects"
					"Zip code fixed effects" 
					"Clusters"
					"Observations"
					"F statistic"
				)
				fmt(0 %20.0fc)
		)
		;

#delimit cr

*******************************************************************************
* End
*******************************************************************************
